#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MAX=1e5+5;
int n,m,L,V;
struct car{
    ll d,v,a;
    int L,R;
    bool bad;
    bool operator<(const car &b)const{
        if(L!=b.L) return L<b.L;
        return R<b.R;
    }
}a[MAX];
int p[MAX];
template<typename T>inline void read(T &x){
    int f=1; x=0; char ch=getchar();
    while(!isdigit(ch)){
        if(ch=='-') f=-f;
        ch=getchar();
    }
    while(isdigit(ch)){
        x=(x<<3)+(x<<1)+(ch-'0');
        ch=getchar();
    }
    x*=f;
}
template<typename T>void write(T x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+48);
}
const ld eps=1e-12;
void solve(){
    int cnt=0,ans=0;
    read(n); read(m); read(L); read(V);
    for(int i=1;i<=n;i++){
        read(a[i].d); read(a[i].v); read(a[i].a);
        a[i].bad=0; 
    }
    for(int i=1;i<=m;i++) read(p[i]);
    for(int i=1;i<=n;i++){
        int t=lower_bound(p+1,p+m+1,a[i].d)-p;
        if(t>m) continue;
        ld d=(ld)((ll)V*V-(ll)a[i].v*a[i].v)/a[i].a/2.0+a[i].d;
        if(a[i].a>0){
            if(d+eps>L) continue;
            if(a[i].v>V) a[i].L=t;
            else a[i].L=upper_bound(p+t,p+m+1,d+eps)-p;
            a[i].R=m;
        }
        else if(a[i].a<0){
            if(a[i].v<=V) continue;
            else{
                a[i].L=t;
                a[i].R=lower_bound(p+t,p+m+1,d-eps)-p-1;
            }
        }
        else{
            if(a[i].v>V){
                a[i].L=t;
                a[i].R=m;
            }
            else continue;
        }
        if(a[i].L<=a[i].R) a[i].bad=1,cnt++;
    }
    //for(int i=1;i<=n;i++) cerr<<a[i].l<<' '<<a[i].r<<' '<<a[i].L<<' '<<a[i].R<<' '<<a[i].bad<<'\n';
    write(cnt); putchar(' ');
    if(cnt==0){
        write(m); putchar('\n');
        return ;
    }
    int l=1,r=L;
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++){
        //cerr<<l<<' '<<r<<' '<<a[i].L<<' '<<a[i].R<<' '<<ans<<'\n';
        if(!a[i].bad) continue;
        int ll=max(l,a[i].L),rr=min(r,a[i].R);
        if(ll>rr){
            ans++;
            l=a[i].L; r=a[i].R;
            continue;
        }
        l=ll; r=rr;
    }
    write(m-ans-1); putchar('\n');
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T; read(T);
    while(T--) solve();
    return 0;
}